<?php
/**
 * View EVENTI - index LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    17-mag-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript">
    //<![CDATA[
     
    $(document).ready(function()
    {
        var pagination = $('#events').pagination({
	    'targetUrl' : '/admin/ajax/list/events',
	    'orderField' : 'event_id',
	    'orderDir' : 'asc'
	}, function(){
            $('tr[class^="result"]').click(function(){
                $(this).siblings().removeClass('selected');
                $(this).toggleClass('selected');
            })            
        });
        
        $( "#searchField" ).keyup( function() {
            if($(this).val().length >= 3)
            {
                var pagination = $('#events').pagination({
                    'targetUrl' : '/admin/search/events/'+ $(this).val(),
                    'orderField' : 'event_id',
                    'orderDir' : 'asc',
                    'perPage' : 2
                }, function(){
                    $('tr[class^="result"]').click(function(){
                        $(this).siblings().removeClass('selected');
                        $(this).toggleClass('selected');
                    })            
                });
            }
            else if($(this).val().length == 0)
            {
                var pagination = $('#events').pagination({
                    'targetUrl' : '/admin/ajax/list/events',
                    'orderField' : 'event_id',
                    'orderDir' : 'asc'
                }, function(){
                    $('tr[class^="result"]').click(function(){
                        $(this).siblings().removeClass('selected');
                        $(this).toggleClass('selected');
                    })            
                });            
            }
        });        
    });

    //]]>
</script>
<div id="content">
    <div id="summary" class="events">
	<div class="head">
	    <h2>Eventi / Rassegne</h2>
	</div>
	<div class="body">Un'Evento/Rassegna &egrave; un insieme di Live (Es: Tour, Rassegne, ecc...)</div>
    </div>
    <form>
	<ul>
	    <li class="addnew">
		<a class="button" href="eventi/info">
		    <img src="/images/admin/16x16/add-new.png" />Crea Nuovo Evento/Rassegna
		</a>
	    </li>
            <li class="likert col3">
	    <table cellspacing="0">
		<caption>
		    Tot: <strong><?php echo $this->count_events ?></strong> elementi presenti.
                    <div class="searchBox">
                        <label class="search">Cerca</label>
                        <input class="search" id="searchField" class="text" type="search" value="">
                    </div>
		</caption>
		<thead>
                    <tr>
                        <td class="pagination" colspan="4">
                            <a class="prev" href="javascript: void(0);">&nbsp;</a>
                            <span class="loader">Sto caricando...</span>
                            <a class="next" href="javascript: void(0);">&nbsp;</a>
                        </td>
                    </tr>
		    <tr>
			<th class="sortable default {ref: 'event_name'}">Nome</th>
                        <td class="sortable default {ref: 'event_type'}">Tipo</td>
			<td colspan="2">&nbsp;</td>
		    </tr>
		</thead>
		<tbody id="events">
		    <!-- Questo contenuto verrà rimpiazzato dalla paginazione-->
		</tbody>
		<tfoot>
                    <tr>
                        <td class="pagination" colspan="4">
                            <a class="prev" href="javascript: void(0);">&nbsp;</a>
                            <span class="loader">Sto caricando...</span>
                            <a class="next" href="javascript: void(0);">&nbsp;</a>
                        </td>
                    </tr>
		</tfoot>
	    </table>
	</li>          
	</ul>
    </form>    
</div>